home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / cat3 / GetInt.3 < prev    next >
Text File  |  1994-09-20  |  4KB  |  133 lines

  1.  
  2.  
  3.  
  4. Tcl_GetInt(3)        Tcl Library Procedures
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      Tcl_GetInt, Tcl_GetDouble,  Tcl_GetBoolean  -  convert  from
  12.      string to integer, double, or boolean
  13.  
  14. SYNOPSIS
  15.      #include <tcl.h>
  16.  
  17.      int
  18.      Tcl_GetInt(_i_n_t_e_r_p, _s_t_r_i_n_g, _i_n_t_P_t_r)
  19.  
  20.      int
  21.      Tcl_GetDouble(_i_n_t_e_r_p, _s_t_r_i_n_g, _d_o_u_b_l_e_P_t_r)
  22.  
  23.      int
  24.      Tcl_GetBoolean(_i_n_t_e_r_p, _s_t_r_i_n_g, _b_o_o_l_P_t_r)
  25.  
  26. ARGUMENTS
  27.      Tcl_Interp   *_i_n_t_e_r_p      (in)      Interpreter to  use  for
  28.                                          error reporting.
  29.  
  30.      char         *_s_t_r_i_n_g      (in)      Textual value to be con-
  31.                                          verted.
  32.  
  33.      int          *_i_n_t_P_t_r      (out)     Points to place to store
  34.                                          integer  value converted
  35.                                          from _s_t_r_i_n_g.
  36.  
  37.      double       *_d_o_u_b_l_e_P_t_r   (out)     Points to place to store
  38.                                          double-precision
  39.                                          floating-point     value
  40.                                          converted from _s_t_r_i_n_g.
  41.  
  42.      int          *_b_o_o_l_P_t_r     (out)     Points to place to store
  43.                                          boolean  value  (0 or 1)
  44.                                          converted from _s_t_r_i_n_g.
  45. _________________________________________________________________
  46.  
  47.  
  48. DESCRIPTION
  49.      These  procedures  convert  from  strings  to  integers   or
  50.      double-precision    floating-point    values   or   booleans
  51.      (represented as 0- or 1-valued integers).  Each of the  pro-
  52.      cedures  takes a _s_t_r_i_n_g argument, converts it to an internal
  53.      form of a particular type, and stores the converted value at
  54.      the  location  indicated  by the procedure's third argument.
  55.      If all goes well, each of the procedures returns TCL_OK.  If
  56.      _s_t_r_i_n_g  doesn't  have the proper syntax for the desired type
  57.      then TCL_ERROR is returned, an  error  message  is  left  in
  58.      _i_n_t_e_r_p->_r_e_s_u_l_t,  and  nothing is stored at *_i_n_t_P_t_r or *_d_o_u_b_-
  59.      _l_e_P_t_r or *_b_o_o_l_P_t_r.
  60.  
  61.  
  62.  
  63. Tcl                                                             1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Tcl_GetInt(3)        Tcl Library Procedures
  71.  
  72.  
  73.  
  74.      Tcl_GetInt expects _s_t_r_i_n_g to  consist  of  a  collection  of
  75.      integer digits, optionally signed and optionally preceded by
  76.      white space.  If the first  two  characters  of  _s_t_r_i_n_g  are
  77.      ``0x''  then  _s_t_r_i_n_g  is expected to be in hexadecimal form;
  78.      otherwise, if the first character of _s_t_r_i_n_g  is  ``0''  then
  79.      _s_t_r_i_n_g  is  expected to be in octal form;  otherwise, _s_t_r_i_n_g
  80.      is expected to be in decimal form.
  81.  
  82.      Tcl_GetDouble expects _s_t_r_i_n_g to consist of a  floating-point
  83.      number,  which  is:   white  space;   a  sign; a sequence of
  84.      digits;  a decimal point;  a sequence of digits;  the letter
  85.      ``e'';   and  a  signed decimal exponent.  Any of the fields
  86.      may be omitted, except that  the  digits  either  before  or
  87.      after  the decimal point must be present and if the ``e'' is
  88.      present then it must be followed by the exponent number.
  89.  
  90.      Tcl_GetBoolean expects _s_t_r_i_n_g to specify  a  boolean  value.
  91.      If   _s_t_r_i_n_g   is   any   of  0,  false,  no,  or  off,  then
  92.      Tcl_GetBoolean stores a zero value at *_b_o_o_l_P_t_r.   If  _s_t_r_i_n_g
  93.      is any of 1, true, yes, or on, then 1 is stored at *_b_o_o_l_P_t_r.
  94.      Any of these values may be abbreviated, and upper-case spel-
  95.      lings are also acceptable.
  96.  
  97.  
  98. KEYWORDS
  99.      boolean, conversion, double, floating-point, integer
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Tcl                                                             2
  130.  
  131.  
  132.  
  133.